import 'package:flutter/cupertino.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter_module/page/demo_test_page.dart';
import 'package:flutter_module/page/demo_test_page2.dart';

class RouteConfigs {
  static Map<String, FlutterBoostRouteFactory> routerMap = {
    'mainPage': (RouteSettings settings, String? uniqueId) {
      return CupertinoPageRoute(
          settings: settings,
          builder: (_) {
            // Map<String, Object> map = settings.arguments as Map<String, Object>;
            // String data = map['data'] as String;
            return DemoTestPage();
          });
    },
    'simplePage': (settings, uniqueId) {
      return CupertinoPageRoute(
          settings: settings,
          builder: (_) {
            Map<String, Object> map = settings.arguments as Map<String, Object>;
            String data = map['data'] as String;
            return DemoTestPage2();
          });
    },
  };

  static Route<dynamic>? routeFactory(
      RouteSettings settings, String? uniqueId) {
    print('${settings.name} 13123');

    FlutterBoostRouteFactory? func = routerMap[settings.name];
    if (func == null) {
      return null;
    }
    Route<dynamic>? route = func(settings, uniqueId);
    return route;
  }
}
